Hệ thống quản lý ISP trong PHP

1 <?php include 'includes/header.php'; ?>
2 <?php
3     require_once
"includes/classes/admin-class.php";
4     $admins =
new Admins($dbh);
5     
if (isset($_POST['quantity'])) {
6         $proselect = $_POST[
'proselect'];
7         $quantity = $_POST[
'quantity'];
8         $date = $_POST[
'date'];
9         $provider = $_POST[
'provider'];
10         $recipient = $_POST[
'recipient'];
11         $remarks = $_POST[
'remarks'];
12         $type = $_POST[
'type'];
13         
if (!$admins->cashCollect($quantity, $date, $provider, $recipient, $remarks, $type))
14         {
15             $msg =
"<i class=\"warning\">Sorry Data could not be inserted !</i>";
16         }
else {
17             $msg =
"<i class=\"success\">Well! You've successfully inserted new data!</i>";
18         }
19     }
20     $page = isset($_GET[
'p' ])?$_GET[ 'p' ]:'';
21     
if($page == 'del'){
22             $id = $_POST[
'id'];
23             
if (!$admins->deleteProduction($id))
24             {
25                 $msg =
"Sorry Data could not be deleted !";
26             }
else {
27                 $msg =
"Well! You've successfully deleted a product!";
28             }
29     }
30 ?>
31 <!-- Income products -->
32     <div
class="col-md-12 col-sm-12">
33         <div
class="panel panel-default">
34             <div
class="panel-heading">
35             <h4>Cash Collection : <a href=
"collection.php" class="btn btn-default btn-sm "> Get all History </a><?php if (isset($msg)) {echo "$msg";} ?></h4>
36             </div>
37             <div
class="panel-body">
38                 <div
class="col-md-12">
39                     <form
class="form-inline" action="collection.php" method="POST">
40                         <!-- <input type=
"hidden" name="recipient" value=""> -->
41                         <!-- <div
class="form-group">
42                             <label
for="proselect"></label>
43                             <
select class="form-control select-form-control" name="proselect" id="proselect" required disabled>
44                                 <option selected disabled
value="" ="">Select an option</option>
45                                         <?php
46                                             
//$collection = $admins->fetchCollection();
47                                             
//if (isset($collection) && sizeof($collection) > 0){
48                                             
//foreach ($collection as $collect) {
49                                             
//}}
50                                         ?>
51                             </
select>
52                         </div> -->
53                     <div
class="form-group">
54                         <label
class="sr-only" for="date">Date</label>
55                         <input type=
"date" class="form-control" name="date" value="<?php echo date("Y-m-d"); ?>">
56                     </div>
57                     <div
class="form-group">
58                         <label
class="sr-only" for="amount">Amount</label>
59                         <input type=
"number" class="form-control" name="amount" placeholder="Amount" required="">
60                     </div>
61                     <div
class="form-group">
62                         <label
class="sr-only" for="from">From</label>
63                         <input type=
"text" class="form-control" name="from" placeholder="From" required="">
64                     </div>
65                     <div
class="form-group">
66                         <label
class="sr-only" for="remarks">Remarks</label>
67                         <input type=
"textarea" class="form-control" name="remarks" placeholder="Remarks" >
68                     </div>
69                       <button type=
"submit" class="btn btn-primary">Collect</button>
70                     </form>
71                     <br>
72                 <table id=
"grid-basic" class="table table-striped table-bordered">
73                         <thead
class="thead-inverse">
74                             <tr
class="info">
75                                 <th>ID </th>
76                                 <th>Date</th>
77                                 <th>Amount</th>
78                                 <th>From</th>
79                                 <th>Remarks</th>
80                                 <th>Action</th>
81                             </tr>
82                         </thead>
83                         <tbody>
84                             <?php
85                             $collection = $admins->fetchCollectin();
86                             
if (isset($collection) && sizeof($collection) > 0){
87                             
foreach($collection as $collect) {
88                             ?>
89                             <tr>
90                                 <td><?=$collect->id?></td>
91                                 <td><?=date(
"jS F y",strtotime($collect->created_at))?></td>
92                                 <td><?=$collect->amount?></td>
93                                 <td><?=$collect->payee?></td>
94                                 <td><?=$collect->remarks?></td>
95                                 <td><button type=
"button" data-id="<?=$collect->id?>" class="btn btn-danger btn-sm delete disabled">DELETE</button></td>
96                             </tr>
97                         <?php }} ?>
98                         </tbody>
99                     </table>
100                 </div>
101             </div>
102         </div>
103     </div>
104
105
106
107 <!-- Expanse products -->
108 <div
class="col-md-12 col-sm-12">
109     <div
class="panel panel-default">
110         <div
class="panel-heading">
111         <h4>Expanse : <a href=
"expanse.php" class="btn btn-default btn-sm "> Get all History </a><?php if (isset($msg)) {echo "$msg";} ?></h4>
112         </div>
113         <div
class="panel-body">
114             <div
class="col-md-12">
115                 <form
class="form-inline" action="expanse.php" method="POST">
116                         <!-- <input type=
"hidden" name="recipient" value=""> -->
117                         <!-- <div
class="form-group">
118                             <label
for="proselect"></label>
119                             <
select class="form-control select-form-control" name="proselect" id="proselect" required disabled>
120                                 <option selected disabled
value="" ="">Select an option</option>
121                                 <?php
122                                     
//$collection = $admins->fetchCollection();
123                                     
//if (isset($collection) && sizeof($collection) > 0){
124                                     
//foreach ($collection as $collect) {
125                                     
//}}
126                                 ?>
127                             </
select>
128                         </div> -->
129                         <div
class="form-group">
130                             <label
class="sr-only" for="date">Date</label>
131                             <input type=
"date" class="form-control" name="date" value="<?php echo date("Y-m-d"); ?>">
132                         </div>
133                         <div
class="form-group">
134                             <label
class="sr-only" for="amount">Amount</label>
135                             <input type=
"number" class="form-control" name="amount" placeholder="Amount" required="">
136                         </div>
137                         <div
class="form-group">
138                             <label
class="sr-only" for="for">For/To</label>
139                             <input type=
"text" class="form-control" name="for" placeholder="For/To" required="">
140                         </div>
141                         <div
class="form-group">
142                             <label
class="sr-only" for="remarks">Remarks</label>
143                             <input type=
"textarea" class="form-control" name="remarks" placeholder="Remarks" >
144                         </div>
145                     <button type=
"submit" class="btn btn-primary">Expanse</button>
146                 </form>
147                 <br>
148             <table id=
"grid-basic" class="table table-striped table-bordered" id="grid-basic">
149                     <thead
class="thead-inverse">
150                         <tr
class="info">
151                             <th>ID </th>
152                             <th>Date</th>
153                             <th>Amount</th>
154                             <th>Purpose</th>
155                             <th>Remarks</th>
156                             <th>Action</th>
157                         </tr>
158                     </thead>
159                     <tbody>
160                         <?php
161                         $expanse = $admins->fetchExpanse();
162                         
if (isset($expanse) && sizeof($expanse) > 0){
163                             
foreach($expanse as $exp) {
164                             ?>
165                             <tr>
166                                 <td><?=$exp->id?></td>
167                                 <td><?=date(
"jS F y",strtotime($exp->created_at))?></td>
168                                 <td><?=$exp->amount?></td>
169                                 <td
class="search"><?=$exp->purpose?></td>
170                                 <td><?=$exp->remarks?></td>
171                                 <td><button type=
"button" data-id="<?=$exp->id?>" class="btn btn-danger btn-sm delete disabled">DELETE</button></td>
172                             </tr>
173                         <?php }} ?>
174                     </tbody>
175                 </table>
176             </div>
177         </div>
178     </div>
179 </div>
180
181
182 <?php include
'includes/footer.php'; ?>
183 <script type=
"text/javascript">
184     document.getElementById(
'date').valueAsDate = new Date();
185     $(
'table').on('click', '.delete', function(e){
186         
var id = $(this).attr("data-id");
187         
var tr = $(this).closest("tr");
188             $.ajax({
189                 method:
"POST",
190                 url:
"collection.php?p=del",
191                 data:
"id="+id,
192                 success: function (data){
193                     
//alert(id);
194                     
//$tr.remove();
195                 }
196             });
197         $(
this).closest('tr').fadeOut(500);
198     });
199 </script>
200     <script type=
"text/javascript">
201       $(function() {
202         grid = $(
'#grid-basic');
203
204         
// handle search fields of members key up event
205         $(
'#search').keyup(function(e) {
206           text = $(
this).val(); // grab search term
207
208           
if(text.length > 1) {
209             grid.find(
'tr:has(td)').hide(); // hide data rows, leave header row showing
210
211             
// iterate through all grid rows
212             grid.find(
'tr').each(function(i) {
213               
// check to see if search term matches Name column
214               
if($(this).find('.search').text().toUpperCase().match(text.toUpperCase()))
215                 $(
this).show(); // show matching row
216             });
217           }
218           
else
219             grid.find(
'tr').show(); // if no matching name is found, show all rows
220         });
221         
222       });
223     </script>


Gõ tìm kiếm nhanh...